package com.maxima.maximaAttendance.daos;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;

import com.maxima.maximaAttendance.pojos.Holiday;
import com.maxima.maximaAttendance.utils.HibernateUtils;

public class HolidayDAO {
	
	@SuppressWarnings("unchecked")
	public List<Holiday> getAllHolidays()
	{
		Session session = HibernateUtils.getSession();
		session.beginTransaction();
		List<Holiday> holidays = null;
		try {
			
			holidays = (List<Holiday>)session.createQuery("select h from Holiday h").list();
			
		} catch (HibernateException e) {
			e.printStackTrace();
			session.getTransaction().rollback();
		}
		session.getTransaction().commit();
		//session.close();
		return holidays;
	}
}
